unit PesquisaConfiguracaoCheque;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, UFormPesquisa, DB, DBTables, StdCtrls, Grids, DBGrids, Buttons,
  ExtCtrls, DBCtrls;

type
  TFPesquisaConfiguracaoCheque = class(TFormPesquisa)
    DBLCBConta: TDBLookupComboBox;
    Label1: TLabel;
    DSConta: TDataSource;
    procedure BtnSelecionarClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure DBLCBContaKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure BtnConsultarClick(Sender: TObject);
    procedure BtnLimparClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FPesquisaConfiguracaoCheque: TFPesquisaConfiguracaoCheque;

implementation

uses ConfiguracaoCheque, UDmFinanceiro;

{$R *.dfm}

procedure TFPesquisaConfiguracaoCheque.BtnSelecionarClick(Sender: TObject);
begin
  inherited;
 FCadastroConfCheque.QConfCheque.Close;
 FCadastroConfCheque.QConfCheque.Open;
 FCadastroConfCheque.QConfCheque.Locate('CONF_CH_CODIGO',QPesquisa.fieldByname('CONF_CH_CODIGO').AsString,[loCaseInsensitive]);
 Self.Close;

end;

procedure TFPesquisaConfiguracaoCheque.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
 FCadastroConfCheque.Enabled:=true;
 FCadastroConfCheque.Show;
 FPesquisaConfiguracaoCheque:=nil;
 inherited;
end;

procedure TFPesquisaConfiguracaoCheque.DBLCBContaKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  case key of
  116 : begin //F5
          TDBLookupComboBox(Sender).ListSource.DataSet.Close;
          TDBLookupComboBox(Sender).ListSource.DataSet.Open;
        end ;
 end;

end;

procedure TFPesquisaConfiguracaoCheque.BtnConsultarClick(Sender: TObject);
begin
 QPesquisa.Close;
 QPesquisa.SQL.Clear;
 QPesquisa.SQL.Add('Select Cont_corr_Descricao,CONFIGURACAO_CHEQUE.* from CONFIGURACAO_CHEQUE inner join ContaCorrente on CONF_CH_CODIGO = Cont_corr_Codigo');
 QPesquisa.SQL.Add('Where (CONF_CH_CODIGO = CONF_CH_CODIGO) ');
 if DBLCBConta.Text <> '' then
  begin
   QPesquisa.SQL.Add(' And (CONF_CH_CODIGO = :Conta) ');
   QPesquisa.ParamByName('Conta').AsInteger:=DBLCBConta.KeyValue;
  end;
 QPesquisa.SQL.Add(' Order By CONF_CH_CODIGO ');
 QPesquisa.Open;
 inherited;
 BtnImprimir.Enabled:=false;
end;

procedure TFPesquisaConfiguracaoCheque.BtnLimparClick(Sender: TObject);
begin
  inherited;
 DBLCBConta.KeyValue:=null;
end;

end.
